// @use '../focus';
@use '../partials/mixin' as mx;

.CSS_START_components_annotations {
  display: none;
}

.annotations_tab {
  display: flex;
  flex-direction: column;
  gap: 5px;

  ol {
    padding: 0;
    margin: 0;
  }
}

.popover_dialog_reader .settings_tab.annotations_tab {
  margin-top: 15px !important;
}

.separator {
  border-bottom: 1px solid var(--color-gray-100);
  padding-bottom: 10px;
}

.annotations_options {
  z-index: 10;
  width: fit-content;
  display: flex;
  align-items: center;
  justify-content: start;
  color: var(--color-brand-primary);
  font-size: 14px;

  span svg {
    fill: var(--color-brand-primary);
    width: 20px;
    height: 20px;
    margin: 0 0.75em;
    padding-top: 5px;
    padding-bottom: 0;
  }

  svg {
    fill: var(--color-brand-primary);
    width: 14px;
    height: 14px;
    margin-right: 0.5em;
  }

  &[open] > span svg {
    transform: rotate(180deg);
    padding-bottom: 5px;
    padding-top: 0;
  }

  .annotations_checkbox {
    display: flex;
    align-items: start;
    padding: 5px;
    height: fit-content;
    margin-left: 15px;

    label {
        margin: 0;
        height: fit-content!important;
    }
  }
}

.annotations_sorting {
  &_container {
    background-color: var(--color-gray-50);
    width: fit-content;
    // border: 1px solid var(--color-gray-300);
    padding: 15px 5px;
    box-shadow: 0 0 5px var(--color-gray-300);
    z-index: 1000;
    border-radius: 5px;

    @include mx.scrollbar_styling;

    &::-webkit-scrollbar-track {
      background-color: var(--color-gray-50);
    }

    & .my_item {
      font-weight: 600;
      outline: solid 2px transparent !important;
      border-radius: 4px;

      &::before {
        background-color: var(--color-brand-primary) !important;
      }
    }
  }
}

.annotations_filter {
  &_container {
    background-color: var(--color-gray-50);
    width: 290px;
    // border: 1px solid var(--color-gray-300);
    padding: 15px;
    padding-right: 5px;
    padding-bottom: 0;
    box-shadow: 0 0 5px var(--color-gray-300);
    z-index: 1000;
    border-radius: 5px;
    overflow-y: scroll;

    .annotations_checkbox {
      color: var(--color-text-primary);
    }

    .button_primary_blue:hover {
      // color: var(--color-neutral-base);
      background-color: var(--color-brand-primary);
    }

    @include mx.scrollbar_styling;

    &::-webkit-scrollbar-track {
      background-color: var(--color-gray-50);
    }
  }

  &_nbOfFilters {
    position: absolute;
    color: var(--color-neutral-base);
    width: 10px;
    height: 10px;
    padding: 4px;
    border-radius: 50px;
    background-color: var(--color-brand-primary);
    top: -8px;
    right: -8px;
    margin: 0;
    line-height: 0.9;
  }

  &_button {
    border: 1px solid var(--color-text-primary);
    border-radius: 5px;
    padding: 0 10px;
  }

  &_line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: calc(100%);
    gap: 20px;
    padding-right: 10px;
  }

  &_trigger_button {
    width: 30px;
    height: 30px;
    position: relative;
    padding: 5px;

    svg {
      width: 20px;
      height: 20px;
      color: var(--color-brand-primary);
      cursor: pointer;
    }
  }

  &_taglist {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin: 20px 0;
  }

  &_tagGroup {
    font-family: inherit;
    background-color: var(--color-neutral-base);
    border-radius: 5px;
    padding: 0 20px;
    height: 45px;
    font-size: 15px;
    line-height: 1;
    box-shadow: 0 3px 3px var(--color-gray-275);
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--color-text-primary);

    &:hover {
      background-color: var(--color-brand-secondary);
    }
  }

  &_tag {
    font-size: 13px;
    padding: 2px 4px;
    border-radius: 5px;
    border: 1px solid var(--color-brand-primary);
    background-color: var(--color-brand-secondary);
    color: var(--color-brand-primary);

    &[data-selected], &:has(input:checked), &[data-state="checked"] {
      color: var(--color-neutral-base);
      background-color: var(--color-brand-primary);

        &:focus {
            outline: var(--color-brand-primary) solid 2px !important;
            outline-offset: 2px;
        }
    }
  }

  &_color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--color-gray-50);

    &[data-selected] {
      outline: 2px solid;
      outline-offset: 2px;
    }
  }

  &_drawtype {
    width: 20px;
    height: 20px;
    padding: 5px;
    border-radius: 5px;

    svg {
      width: 20px;
      height: 20px;
      color: var(--color-text-primary);
    }

    &[data-selected] {
      background-color: var(--color-brand-primary);

      svg {
        color: var(--color-neutral-base);
      }
    }
  }
}

.settings_tab .annotation_actions {
  @media screen and (width <= 800px) {
    flex-direction: column!important;
    align-items: start!important;
  }
}

.popover_dialog_reader .annotation_actions {
  flex-direction: column;
  align-items: start;
  gap: 10px;
}

.annotation_form {
    background-color: var(--color-gray-50);
    max-width: 450px;
    border-radius: 6px;
    border: 1px solid var(--color-gray-300);
    display: flex;
    flex-direction: column;
    padding: 5px 10px;
    color: var(--color-text-primary);

    // gap: 10px;

    h4 {
      margin: 5px 0;
    }

    label {
      margin: 5px;
    }

    &_textarea{
      width: 420px;
      min-width: 420px;
      height: 100px;
      min-height: 100px;
      max-width: 420px;
      border: 1px solid rgb(118 118 118);
      border-radius: 3px;
      font-family: Nunito, sans-serif;
      background-color: var(--color-annotation-textarea);
      color: var(--color-text-primary);


      &_container {
      display: flex;
      flex-direction: column;
      }

      &_buttons {
        margin: 5px 0;
        display: flex;
        gap: 5px;

        button {
          min-width: unset;
          width: fit-content;
          height: 25px;

          &.button_primary_blue {
            color: var(--color-neutral-base);

            &:hover, &:focus:hover {
              color: var(--color-brand-primary)!important;
            }
          }

          svg {
            fill: var(--color-neutral-base);
            color: var(--color-neutral-base);
          }

          &:hover svg {
            fill: var(--color-brand-primary);
            color: var(--color-brand-primary);
          }
        }
      }
    }
  }

  .annotation_actions {
    display: flex;
    align-items: center;
    gap: 30px;
    margin: 10px 0 20px;
    flex-wrap: wrap;

    &_container {
      display: flex;
      flex-direction: column;
      justify-content: start;

      .react_aria_ComboBox {
        margin: 0;
        padding: 0;
        width: inherit;

        .react_aria_Label {
          width: 100%;
          text-align: left;
        }

        .my_combobox_container {
          background-color: var(--color-neutral-base);
          width: inherit;

          input {
            padding: 0 10px 0 30px !important;
            width: 100%;
          }

          button {
            margin-left: 0;
            padding-left: 0!important;
          }
        }
      }
    }

    >div {
      display: inherit;

      >div {
        display: flex;
        // gap: 5px;
        align-items: center;
      }

      p {
        margin: 0;
      }

      svg {
        width: 20px;
        height: 20px;
      }
    }

    &_buttons {
      button:disabled {
        border-radius: 5px;
        background-color: var(--color-gray-250);

        svg {
          fill: var(--color-text-primary);
          color: var(--color-text-primary);
        }
      }

      svg {
        fill: var(--color-brand-primary-inverse);
        color: var(--color-brand-primary-inverse);
      }
    }
  }

  .annotation_edit_form {
    display: flex;
    flex-direction: column;

    p {
      background-color: var(--color-gray-50);
      // width: 95%!important;
      border-radius: 5px;
      margin-bottom: 10px!important;
    }

    &_textarea{
      min-width: 95%;
      max-width: 95%;
      min-height: 30px;
      border: 1px solid var(--color-text-primary);
      border-radius: 3px;
      font-family: Nunito, sans-serif;
      overflow: hidden;
      color: var(--color-text-primary);
      background-color: var(--color-neutral-base);

      &_container {
      display: flex;
      flex-direction: column;
      }

      &_buttons {
        margin: 5px 0;
        display: flex;
        gap: 5px;
      }
    }
  }

  .colorPicker {
    display: flex;
    background-color: var(--color-button-hover);
    padding: 2px;
    gap: 1px;
    border: 1px solid var(--color-gray-900);
    border-radius: 6px;

    &:has(input:focus) {
      @include mx.R2_MIXIN_FOCUS_OUTLINE;
    }

    div {
        input {
            position: absolute;
            z-index: -1;
        }

        label {
            z-index: 20;
            width: 25px;
            height: 25px;
            margin: 0;
            border: 1px solid var(--color-neutral-base);
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 5px;
            cursor: pointer;
        }
    }

    svg {
      color: #4d4d4d;
    }
  }

  .stylePicker {
  display: flex;
  padding: 2px;
  gap: 10px;
  border-radius: 5px;

  &:has(input:focus) {
    @include mx.R2_MIXIN_FOCUS_OUTLINE;
  }

  div {
      input {
          position: absolute;
          z-index: -1;
      }

      label {
          z-index: 20;
          width: 27px;
          height: 27px;
          margin: 0;
          background-color: inherit;
          cursor: pointer;
          border-radius: 3px;
          display: flex;
          align-items: center;
          justify-content: center;

          svg {
            color: var(--color-brand-primary-inverse);
          }
      }
  }
  }

  .drawType_active {
    background-color: var(--color-brand-primary)!important;

    svg {
      color: var(--color-neutral-base)!important;
      fill: var(--color-neutral-base)!important;
    }
  }

  .settings_tab .annotations_line {
    width: 100%;
    list-style-type: none;
  }

  .annotations_line {
    // width: 100%;
    position: relative;
    text-align: left;
    font-size: 1rem;
    border-left: 2px solid var(--color-brand-primary);
    padding-left: 10px;
    margin: 0;
    margin-bottom: 10px;
    background-color: var(--color-annotation-bg);
    margin-top: 10px;

    p {
      text-align: left;
      // background-color: var(--color-annotation-text);

      // overflow: hidden;
      // text-overflow: ellipsis;
      // width: calc(100% - 15px);
      width: fit-content;

      // display: -webkit-box;
      // -webkit-box-orient: vertical;
      // -webkit-line-clamp: 3;
      padding: 8px;
      margin: 5px 0;
    }

    // @media (prefers-color-scheme: dark) {
    //   background-color: #2D2D2D;
    // }

    .annnotation_container {
      // margin-top: 10px;
      margin-right: 10px;
      padding-top: 10px;

      .tag a {
        font-size: 14px;
      }

    }

    .annnotation_container:has(.annotation_name:focus) {
      outline: 2px solid var(--color-brand-primary);
      border-radius: 5px;
    }

    .annotation_name {
      background-color: var(--color-annotation-text);
      border-bottom: 8px solid var(--color-annotation-text);
      height: unset;
      font-family: Nunito, sans-serif;
      border-radius: 5px;
      width: 100%;

      p {
        text-align: left;
        overflow: hidden;
        text-overflow: ellipsis;
        width: 100%;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 4;
        margin: 0;
        padding: 8px;
        padding-bottom: 0;
      }

      // &:focus {
      //   outline: 2px solid var(--color-brand-primary);
      // }
    }

    .update_form input {
      width: 100%;
      border-radius: 6px;
    }

    & > button {
      border: none;
      background-color: transparent;
      cursor: pointer;
      padding: 0;

      & svg {
        width: 24px;
      }
    }

    & img {
      width: 30px;
      height: 30px;
      display: inline-block;
      vertical-align: top;
    }

    // & .chapter_marker {
    //   vertical-align: top;
    //   position: relative;
    //   display: inline-block;
    //   flex: 1;
    //   font-size: 0.9rem;
    //   margin-right: 0.5rem;
    // }

    & span {
      display: inline-block;
      vertical-align: top;
      margin-top: 5px;
      word-break: normal;
      /* overflow-wrap: break-word; */
      overflow-wrap: anywhere;
      white-space: normal;
    }

    .annotation_edit {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 5px;

      p {
        padding-left: 0;
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      >div {
        display: inherit;
        align-items: center;
        overflow: hidden;
        padding: 2px;

        button {
          padding: 5px;
          border-radius: 5px;
        }

        >div {
          display: flex;
          gap: 5px;
          align-items: center;

          a {
            &:hover {
              cursor: pointer;
              text-decoration: underline;
            }
          }
        }

        svg {
          width: 18px;
          height: 18px;
        }
      }
    }
  }

.docked_annotation_line {
  border-left: 2px solid var(--color-brand-primary);
  padding: 0 10px;
  margin-top: 5px;
}

.annotationsTitle_form {
  &_container {
    width: fit-content;
    height: fit-content;
    border: none;
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 0 15px;
    color: var(--color-text-primary);

    .form_group {
      width: unset;
      border-radius: 6px;
      background-color: var(--color-neutral-base);
    }

    input {
      width: 100%;
      padding: 0;
      height: 22px;
      margin-left: 10px;
      margin-right: 1px;
      border-radius: 6px;
      background-color: var(--color-neutral-base);
    }

    label {
      background: linear-gradient(180deg, var(--color-gray-50) 0%, var(--color-gray-50) 50%, var(--color-neutral-base) 50%, var(--color-neutral-base) 100%);
      top: -5px;
    }

    button {
      width: 100%;
      height: 25px;
    }

    p {
      margin: 0;
    }

    select {
      background-color: var(--color-neutral-base);
      color: var(--color-text-primary);
    }

  }
}

.CSS_END_components_annotations {
  display: none;
}
